home *** CD-ROM | disk | FTP | other *** search
/ Total Web Page (Professional Suite) / Total Web Page 99.iso / Javascripts / miscellanious / fadedtext_.txt < prev    next >
Text File  |  1998-10-30  |  4KB  |  136 lines

  1. <HEAD>
  2. <TITLE>Faded Text</TITLE>
  3. </HEAD>
  4.  
  5. <body bgcolor="ffffff">
  6. <script>
  7. <!-- Hide the script from old browsers --
  8. function MakeArray(n){   
  9.     this.length=n;   
  10.     for(var i=1; i<=n; i++) this[i]=i-1;   
  11.         return this
  12.     }
  13.     hex=new MakeArray(16);
  14.     hex[11]="A"; 
  15.     hex[12]="B"; 
  16.     hex[13]="C"; 
  17.     hex[14]="D"; 
  18.     hex[15]="E"; 
  19.     hex[16]="F";
  20.  
  21. function ToHex(x){              
  22.     // Changes a int to hex (in the range 0 to 255)   
  23.     var high=x/16;   
  24.     var s=high+"";               
  25.     //1   
  26.     s=s.substring(0,2);          
  27.     //2 the combination of these are the same as the trunc function   
  28.     high=parseInt(s,10);         
  29.     //3   
  30.     var left=hex[high+1];        
  31.     // left part of the hex-value   
  32.     var low=x-high*16;           
  33.     // calculate the rest of the values   
  34.     s=low+"";                    
  35.     //1   
  36.     s=s.substring(0,2);          
  37.     //2 the combination of these are the same as the trunc function   
  38.     low=parseInt(s,10);          
  39.     //3   
  40.     var right=hex[low+1];        
  41.     // right part of the hex-value   
  42.     var string=left+""+right;    
  43.     // add the high and low together   
  44.     return string;
  45. }
  46.  
  47. function fadein(text){   
  48.     text=text.substring(3,text.length-4);        
  49.     // gets rid of the HTML-comment-tags   
  50.     color_d1=255;                                
  51.     color_d1b=255;
  52.     color_d1c=255;
  53.     // any value in 'begin' 0 to 255   
  54.     mul=color_d1/text.length;   
  55.     for(i=0;i<text.length;i++){      
  56.         color_d1=mul*i; 
  57.         color_d1b=255-mul*i;
  58.         color_d1c=255*Math.sin(i/(text.length/3));
  59.  
  60.         // some other things you can try>> "=255-mul*i" to fade out, "=mul*i" to fade in, or try "255*Math.sin(i/(text.length/3))"      
  61.         color_h1=ToHex(color_d1);      
  62.         color_d2=mul*i;      
  63.         color_h2=ToHex(color_d2);      
  64.         //1b
  65.         color_h1b=ToHex(color_d1b);      
  66.         color_d2b=mul*i;      
  67.         color_h2b=ToHex(color_d2b);      
  68.         //1c
  69.         color_h1c=ToHex(color_d1c);      
  70.         color_d2c=mul*i;      
  71.         color_h2c=ToHex(color_d2c);      
  72.  
  73.         document.write("<FONT COLOR='#FF"+color_h1+color_h2+"'>"+text.substring(i,i+1)+'</FONT>');   
  74.  
  75.     }
  76.     document.write('<p>');
  77.     for(i=0;i<text.length;i++){      
  78.         color_d1=mul*i; 
  79.         color_d1b=255-mul*i;
  80.         color_d1c=255*Math.sin(i/(text.length/3));
  81.  
  82.         // some other things you can try>> "=255-mul*i" to fade out, "=mul*i" to fade in, or try "255*Math.sin(i/(text.length/3))"      
  83.         color_h1=ToHex(color_d1);      
  84.         color_d2=mul*i;      
  85.         color_h2=ToHex(color_d2);      
  86.         //1b
  87.         color_h1b=ToHex(color_d1b);      
  88.         color_d2b=mul*i;      
  89.         color_h2b=ToHex(color_d2b);      
  90.         //1c
  91.         color_h1c=ToHex(color_d1c);      
  92.         color_d2c=mul*i;      
  93.         color_h2c=ToHex(color_d2c);      
  94.  
  95.         document.write("<FONT COLOR='#FF"+color_h1c+color_h2c+"'>"+text.substring(i,i+1)+'</FONT>');   
  96.  
  97.     }
  98.     document.write('<p>');
  99.     for(i=0;i<text.length;i++){      
  100.         color_d1=mul*i; 
  101.         color_d1b=255-mul*i;
  102.         color_d1c=255*Math.sin(i/(text.length/3));
  103.  
  104.         // some other things you can try>> "=255-mul*i" to fade out, "=mul*i" to fade in, or try "255*Math.sin(i/(text.length/3))"      
  105.         color_h1=ToHex(color_d1);      
  106.         color_d2=mul*i;      
  107.         color_h2=ToHex(color_d2);      
  108.         //1b
  109.         color_h1b=ToHex(color_d1b);      
  110.         color_d2b=mul*i;      
  111.         color_h2b=ToHex(color_d2b);      
  112.         //1c
  113.         color_h1c=ToHex(color_d1c);      
  114.         color_d2c=mul*i;      
  115.         color_h2c=ToHex(color_d2c);      
  116.  
  117.         document.write("<FONT COLOR='#FF"+color_h1b+color_h2b+"'>"+text.substring(i,i+1)+'</FONT>');   
  118.  
  119.     }
  120.  
  121. }
  122. // --End Hiding Here -->
  123. </script>
  124. <center><font size=7>Faded Text</font>
  125. <hr width=80%>
  126.  
  127. <SCRIPT LANGUAGE="JavaScript">
  128. <!--   
  129. {
  130.     fadein("-->This is an example of Faded Text.<!__");
  131. }
  132. //-->
  133. </SCRIPT>
  134. </center>
  135. <!-- HINT--Don't forget to add this argument to your BODY tag:  onLoad="ticker()" --></body></html>
  136.